package com.leet.competition;

import java.lang.reflect.Array;
import java.util.*;

public class KthLargestNumber {
    public String kthLargestNumber(String[] nums, int k) {
        PriorityQueue<String> q = new PriorityQueue<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                if(o1.length() != o2.length()){
                    return o2.length()-o1.length();
                }else return o2.compareTo(o1);
            }
        });
        q.addAll(Arrays.asList(nums));
        while(k!=0){
            k--;
            q.poll();
        }
        return q.peek();
    }
}
